Class com.symantec.itools.swing.JChart
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.symantec.itools.swing.JChart

Object
   |
   +----Component
           |
           +----Container
                   |
                   +----JComponent
                           |
                           +----com.symantec.itools.swing.JChart

public class JChart
extends JComponent
implements GraphStyle, TableModelListener
Simple charting component. Creates a chart capable of displaying one or more series of data in the form of a bar, line, scatter, pie, or area chart. The chart uses a standard TableModel interface as the data model type. The TableModel can use several types including: Integer, Double, Long, String, and DataElem

Version:
1.0, July 28, 1998
Author:
Michael Hopkins, Symantec

Variable Index

 o AUTO_CALCULATE_MAX
 o AUTO_CALCULATE_MIN
 o debug
 o graphBorder
 o graphCols
 o graphLower
 o graphMax
 o graphMin
internal data members
 o graphStyle
 o graphUpper
 o gridIncrementH
 o gridIncrementV
 o gridStepV
 o labelYInset
 o legendBorder
 o model
component parameters
 o numTicksY
 o precision
 o showGrid
 o showLegend
 o title
 o titleBorder
 o yAxisMax
 o yAxisMin

Constructor Index

 o com.symantec.itools.swing.JChart()

Method Index

 o calcLabelInset(Graphics)
 o calcTickInterval()
Calculates the interval between tick marks on the horizontal axis
 o calibrateGraph()
 o drawAreaGraph(Graphics)
 o drawAxis(Graphics)
 o drawGrid(Graphics)
 o drawLegend(Graphics)
Draws the legend of the graph
 o drawPieGraph(Graphics)
 o drawPieSeries(Graphics, int, Rectangle, int, int)
 o drawTitle(Graphics)
 o drawYAxisTicks(Graphics)
 o getDataLabel(int, int)
gets the label of a data element associated with a given index of a specific series
 o getGraphBorder()
gets border insets of the graph
 o getMinimumSize()
Get the minimum size of the component
 o getModel()
Gets the current model used by the chart
 o getNumSeries()
Returns the number of data series that are used in the graph
 o getNumYTicks()
gets the number of ticks or major subdivisions displayed on the y axis
 o getPrecision()
gets the precision displayed by the chart.
 o getPreferredSize()
Get the preferred size of the component
 o getSeriesColor(int)
gets the default color of a particular series
 o getSeriesColor(int, int)
gets the color of a particular data element within a series
 o getSeriesName(int)
gets the name of a series associated with a given index
 o getSeriesSize(int)
Gets the size (number of elements) of the series referenced by index i
 o getSeriesValue(int, int)
retrieves a series entry value
 o getShowGrid()
returns whether or not a grid is displayed as an overlay of the data area
 o getStyle()
Gets the new graph style.
 o getTitle()
Gets the title of the graph
 o getYAxisMax()
gets the maximum on the y axis
 o getYAxisMin()
gets the minimum or origin value on the y axis
 o isShowGrid()
returns whether or not a grid is displayed as an overlay of the data area
 o isShowLegend()
returns whether or not the graph is to display a legend
 o paintComponent(Graphics)
Draws the contents of the chart component
 o seriesMax()
finds the highest value (max) in all series
 o seriesMax(int)
finds the highest value (max) in a series
 o seriesMin()
finds the lowest value (min) in all series
 o seriesMin(int)
finds the lowest value (min) in a series
 o seriesSum(int)
finds the sumation of all data points in a given series
 o seriesSumMax()
finds the maximum of the summation of all series entries at a given index
 o setBorder(Border)
Sets the border of the component
 o setGraphBorder(Insets)
sets the border insets of the graph
 o setModel(TableModel)
Sets the current model used by the chart.
 o setNumYTicks(int)
sets the number of ticks or major subdivisions to be displayed on the y axis
 o setPrecision(int)
sets the precision to be displayed by the chart.
 o setShowGrid(boolean)
sets whether or not a grid should be displayed as an overlay of the data area
 o setShowLegend(boolean)
Sets whether the graph is to display a legend or not
 o setStyle(int)
Sets the new graph style.
 o setTitle(String)
Sets the title of the graph
 o setYAxisMax(double)
sets the maximum on the y axis
 o setYAxisMin(double)
sets the minimum or origin value on the y axis
 o tableChanged(TableModelEvent)
Responds to notification of changes in the model data
 o truncDataStr(String)
Graphics utility routines

Variables

 o AUTO_CALCULATE_MAX
public static final double AUTO_CALCULATE_MAX
 o AUTO_CALCULATE_MIN
public static final double AUTO_CALCULATE_MIN
 o debug
protected boolean debug
 o graphBorder
protected java.awt.Insets graphBorder
 o graphCols
protected int graphCols
 o graphLower
protected double graphLower
 o graphMax
protected double graphMax
 o graphMin
protected double graphMin
internal data members

 o graphStyle
protected int graphStyle
 o graphUpper
protected double graphUpper
 o gridIncrementH
protected int gridIncrementH
 o gridIncrementV
protected int gridIncrementV
 o gridStepV
protected double gridStepV
 o labelYInset
protected int labelYInset
 o legendBorder
protected int legendBorder
 o model
protected com.sun.java.swing.table.TableModel model
component parameters

 o numTicksY
protected int numTicksY
 o precision
protected int precision
 o showGrid
protected boolean showGrid
 o showLegend
protected boolean showLegend
 o title
protected java.lang.String title
 o titleBorder
protected int titleBorder
 o yAxisMax
protected double yAxisMax
 o yAxisMin
protected double yAxisMin

Constructors

 o JChart
public JChart()

Methods

 o calcLabelInset
protected void calcLabelInset(Graphics g)
 o calcTickInterval
protected void calcTickInterval()
Calculates the interval between tick marks on the horizontal axis

 o calibrateGraph
protected void calibrateGraph()
 o drawAreaGraph
protected void drawAreaGraph(Graphics g)
 o drawAxis
protected void drawAxis(Graphics g)
 o drawGrid
protected void drawGrid(Graphics g)
 o drawLegend
protected void drawLegend(Graphics g)
Draws the legend of the graph

 o drawPieGraph
protected void drawPieGraph(Graphics g)
 o drawPieSeries
protected void drawPieSeries(Graphics g,
                             int seriesNum,
                             Rectangle frame,
                             int startAngle,
                             int vLabel)
 o drawTitle
protected void drawTitle(Graphics g)
 o drawYAxisTicks
protected void drawYAxisTicks(Graphics g)
 o getDataLabel
public java.lang.String getDataLabel(int series,
                                     int index)
gets the label of a data element associated with a given index of a specific series

Parameters:
series - number of the series to use
index - of the data element to use
Returns:
name of the requested series
See Also:
getSeriesName
 o getGraphBorder
public java.awt.Insets getGraphBorder()
gets border insets of the graph

Returns:
border of the graph
See Also:
setGraphBorder
 o getMinimumSize
public java.awt.Dimension getMinimumSize()
Get the minimum size of the component

Returns:
the minimum dimension of the component
Overrides:
getMinimumSize in class JComponent
 o getModel
public com.sun.java.swing.table.TableModel getModel()
Gets the current model used by the chart

Returns:
the model
See Also:
setModel
 o getNumSeries
public int getNumSeries()
Returns the number of data series that are used in the graph

Returns:
number of series
 o getNumYTicks
public int getNumYTicks()
gets the number of ticks or major subdivisions displayed on the y axis

Returns:
int the number of major subdivisions of the y axis
See Also:
setNumYTicks
 o getPrecision
public int getPrecision()
gets the precision displayed by the chart. Precision is defined as the number of digits after the decimal point that are to be displayed. specifying zero indicates that the number is to be treated as an integer.

Returns:
int the number of places displayed after the decimal
See Also:
setPrecision
 o getPreferredSize
public java.awt.Dimension getPreferredSize()
Get the preferred size of the component

Returns:
the dimension of the component
Overrides:
getPreferredSize in class JComponent
 o getSeriesColor
public java.awt.Color getSeriesColor(int series)
gets the default color of a particular series

Parameters:
series - index of the series to use
Returns:
color associated with the requested series
 o getSeriesColor
public java.awt.Color getSeriesColor(int series,
                                     int index)
gets the color of a particular data element within a series

Parameters:
series - number of the series to use
index - associated with the data element within the series
Returns:
color associated with the requested series
 o getSeriesName
public java.lang.String getSeriesName(int series)
gets the name of a series associated with a given index

Parameters:
series - index of the series to use
Returns:
name of the requested series
 o getSeriesSize
public int getSeriesSize(int i)
Gets the size (number of elements) of the series referenced by index i

Parameters:
i - the index of the series
Returns:
the size of the series
Throws: ArrayIndexOutOfBoundsException
 o getSeriesValue
public double getSeriesValue(int series,
                             int index)
retrieves a series entry value

Parameters:
series - the number of the series to edit
index - the index of the item to edit
Throws: ArrayIndexOutOfBoundsException
 o getShowGrid
public boolean getShowGrid()
Note: getShowGrid() is deprecated. use isShowGrid instead

returns whether or not a grid is displayed as an overlay of the data area

Returns:
true if a grid is displayed
See Also:
setShowGrid
 o getStyle
public int getStyle()
Gets the new graph style.

Returns:
the new border style, one of DEFAULT_STYLE, LINE_STYLE, BAR_STYLE, PIE_STYLE, AREA_STYLE, or SCATTER_STYLE
See Also:
setStyle, DEFAULT_STYLE, LINE_STYLE, BAR_STYLE, PIE_STYLE, AREA_STYLE, SCATTER_STYLE
 o getTitle
public java.lang.String getTitle()
Gets the title of the graph

Returns:
String title of the graph
See Also:
setTitle
 o getYAxisMax
public double getYAxisMax()
gets the maximum on the y axis

Returns:
the maximum value on the y axis
See Also:
setYAxisMax
 o getYAxisMin
public double getYAxisMin()
gets the minimum or origin value on the y axis

Returns:
the minimum or origin value on the y axis
See Also:
setYAxisMin
 o isShowGrid
public boolean isShowGrid()
returns whether or not a grid is displayed as an overlay of the data area

Returns:
true if a grid is displayed
See Also:
getShowGrid
 o isShowLegend
public boolean isShowLegend()
returns whether or not the graph is to display a legend

Returns:
true if graph displays a legend
See Also:
setShowLegend
 o paintComponent
public void paintComponent(Graphics g)
Draws the contents of the chart component

Parameters:
g - the graphics object to be referenced for drawing
Overrides:
paintComponent in class JComponent
 o seriesMax
protected double seriesMax()
finds the highest value (max) in all series

Returns:
max value in given series
Throws: ArrayIndexOutOfBoundsException
See Also:
seriesMax( int num )
 o seriesMax
protected double seriesMax(int num)
finds the highest value (max) in a series

Parameters:
num - the series in which to find the maximum value
Returns:
max value in given series
Throws: ArrayIndexOutOfBoundsException
 o seriesMin
protected double seriesMin()
finds the lowest value (min) in all series

Returns:
min value in given series
Throws: ArrayIndexOutOfBoundsException
See Also:
seriesMin( int num )
 o seriesMin
protected double seriesMin(int num)
finds the lowest value (min) in a series

Parameters:
num - the series in which to find the minimum value
Returns:
min value in given series
Throws: ArrayIndexOutOfBoundsException
 o seriesSum
protected double seriesSum(int num)
finds the sumation of all data points in a given series

Parameters:
num - the series in which to find the sumation
Returns:
sumation of a given series
 o seriesSumMax
protected double seriesSumMax()
finds the maximum of the summation of all series entries at a given index

Returns:
maximum graph summation
 o setBorder
public void setBorder(Border border)
Sets the border of the component

Overrides:
setBorder in class JComponent
 o setGraphBorder
public void setGraphBorder(Insets i)
sets the border insets of the graph

Parameters:
i - graph insets to use
See Also:
getGraphBorder
 o setModel
public void setModel(TableModel newModel)
Sets the current model used by the chart. The model is a TableModel derrivative, and can be composed of objects of type Integer, Long, Double, String, or DataElem

Parameters:
newModel - the TabelModel to be used by the chart
Throws: IllegalArgumentException
if the specified model is null
See Also:
getModel
 o setNumYTicks
public void setNumYTicks(int ticks)
sets the number of ticks or major subdivisions to be displayed on the y axis

Parameters:
ticks - the number of major subdivisions to use for the y axis
See Also:
getNumYTicks
 o setPrecision
public void setPrecision(int places)
sets the precision to be displayed by the chart. Precision is defined as the number of digits after the decimal point that are to be displayed. specifying zero indicates that the number is to be treated as an integer.

Parameters:
places - the number of places to display after the decimal
See Also:
getPrecision
 o setShowGrid
public void setShowGrid(boolean show)
sets whether or not a grid should be displayed as an overlay of the data area

Parameters:
show - true if a grid should be displayed
See Also:
getShowGrid
 o setShowLegend
public void setShowLegend(boolean b)
Sets whether the graph is to display a legend or not

Parameters:
b - true if graph should display a legend
See Also:
isShowLegend
 o setStyle
public void setStyle(int style)
Sets the new graph style.

Parameters:
style - the new border style, one of DEFAULT_STYLE, LINE_STYLE, BAR_STYLE, PIE_STYLE, AREA_STYLE, or SCATTER_STYLE
See Also:
getStyle, DEFAULT_STYLE, LINE_STYLE, BAR_STYLE, PIE_STYLE, AREA_STYLE, SCATTER_STYLE
 o setTitle
public void setTitle(String s)
Sets the title of the graph

Parameters:
s - title of the graph
See Also:
getTitle
 o setYAxisMax
public void setYAxisMax(double max)
sets the maximum on the y axis

Parameters:
max - the maximum value on the y axis
See Also:
getYAxisMax
 o setYAxisMin
public void setYAxisMin(double min)
sets the minimum or origin value on the y axis

Parameters:
min - the minimum or origin value on the y axis
See Also:
getYAxisMin
 o tableChanged
public void tableChanged(TableModelEvent e)
Responds to notification of changes in the model data

Parameters:
e - the event to process
 o truncDataStr
protected java.lang.String truncDataStr(String s)
Graphics utility routines


All Packages  Class Hierarchy  This Package  Previous  Next  Index